#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

bool check(vector<int> a, int l, int r, int t) {
    int s = 0, k = 0;
    for (int j = l; j < r; j++) {
        s += a[j];
        k++;
        while (s > t) {
            s -= a[l++];
            k--;
        }
        if (k >= 2 && s == t) {
            return true;
        }
    }
    return false;
}

void solve() {
    int n;
    int cnt = 0;
    cin >> n;
    vector<int> a(n);
    ll s = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }
    map<int, bool> mp;
    for (int i = 0; i < n; i++) {
        if (a[i] > s)continue;
        if (mp[a[i]] == true) {
            cnt++;
            continue;
        } else if (check(a, 0, n, a[i])) {
            cnt++;
            mp[a[i]] = true;
        }
    }
    cout << cnt << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}